limsMethodCertificateUser.searchPage = {

    getGridParam : function() {
        var _this = this;
        return {
            type : 'grid',
            titleAlign : 'center',
            textAlign: 'center',
            id : 'lims-method-certificate-user-search-list-grid',
            url : limsMethodCertificateUser.baseUrl + '/queries/searchable',
            columns : limsMethodCertificateUser.getSearchListColumns(),
            page:true,
            onLoadSuccess: function (data) {
                if (!Gikam.isEmpty(data)) {
                    this.activeRowByIndex(0)
                } else {
                    _this.refreshTabs(null)
                }
            },
            onRowActive: function (index, row) {
                _this.refreshTabs(row)
            },
            page:true,
            onCellClick : function(field, row) {
                field === 'personCode' && _this.loadDetailPage(row.id);
            }
        }
    },

    refreshTabs: function (row) {
        let _this = this
        Gikam.getAsyncComp(_this.idManager.auditRecordGrid).done(function (comp) {
            if (row && row.id) {
                comp.refresh({
                    url: IFM_CONTEXT + '/secure/core/module/sys/bpmn-comments/queries?table=T_LIMS_METHOD_CERTIFICATE_USER&id=' + row.id,
                })
            } else {
                comp.refresh({
                    url: IFM_CONTEXT + '/secure/core/module/sys/bpmn-comments/queries?table=T_LIMS_METHOD_CERTIFICATE_USER&id=' + 0
                })
            }
        })
        Gikam.getAsyncComp(_this.idManager.certificateGrid).done(function (comp) {
            if (row && row.id) {
                comp.refresh({
                    url : limsMethodCertificate.baseUrl + '/queries/raw',
                    requestData : {
                        personId_EQ : row.id
                    },
                })
            } else {
                comp.cleanData()
            }
        })
    },


    getBaseInfoTab: function () {
        var _this = this
        return {
            type: 'tab',
            panels: [{
                title: 'BASEMODULE.COREDATA.METHODS.TAB.BASE_INFO',
                items: [_this.getAttachmantStruct()]
            }, {
                title: 'T_CORE_FILE.OPERATE.OPERATION.RECORD',
                items: [_this.getAuditRecordGrid()]
            }]
        }
    },

    getAttachmantStruct: function () {
        let _this = this
        return  {
            type : 'grid',
            id : _this.idManager.certificateGrid,
            page:true,
            service : 'limsMethodCertificateServiceImpl',
            dbTable : 'T_LIMS_METHOD_CERTIFICATE',
            readonly:true,
            columns : limsMethodCertificate.getEditListColumns(),
        }
    },


    getAuditRecordGrid: function () {
        let _this = this
        return {
            type: 'grid',
            id: _this.idManager.auditRecordGrid,
            columns: limsMethodCertificate.getFlowListColumns(),
            readonly:true,
        }
    },

    idManager: {
        certificateGrid: 'lims-method-certificate-search-list-grid',
        auditRecordGrid: 'lims-method-certificate-search-list-grid' + '-record',
    },
    create : function() {
        var _this = this;
        Gikam.create('layout', {
            id : 'lims-method-certificate-user-search-list-layout',
            renderTo : workspace.window.$dom,
            center: {
                //height: '55%',
                items: [this.getGridParam()]
            },
            /*center: {
                items: [this.getBaseInfoTab()]
            }*/
        });
    },

    loadDetailPage : function(id) {
        workspace.window.load(limsMethodCertificate.baseUrl + '/page/detail' + Gikam.param({
            id : id,
            readonly:3,//没有按钮
        }));
    },

    init : function() {
        this.create();
    }
};
